/**
 * 
 */
package view.impl.ingame;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.newdawn.slick.Graphics;

/**
 * @author Julian
 *
 */
public class GameStage {
	private List<IGameObject> objects = new LinkedList<IGameObject>();
	
	private Fighter[] fighters = new Fighter[2];
	
	//private String name, prettyName;
	
	/*
	GameStage(String name, String prettyName) {
		this.name = name;
		this.prettyName = prettyName;
	}
	*/
	
	void addGameObject(IGameObject obj) {
		objects.add(obj);
		
		Collections.sort(objects);
	}
	
	void addFighter(Fighter fighter) {
		if(fighters[0] == null) {
			fighters[0] = fighter;
		}
		else {
			fighters[1] = fighter;
		}
		objects.add(fighter);
	}
	
	public void draw(EffectDispatch ed, Graphics g, int windowWidth, int windowHeight) {
		for(IGameObject o : objects) {
			o.draw(g, windowWidth, windowHeight);
		}
		for(Fighter f : fighters) {
			f.addEffects(ed, g, windowWidth, windowHeight);
		}
	}
	
	public Fighter getFighter(Fighter.Player player) {
		return fighters[0].getPlayer() == player? fighters[0] : fighters[1];
	}
}
